﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Majoopic.Utility;
using Majoopic.Service.Model;
using Majoopic.Service.Interface;

namespace Majoopic.Service
{
    /// <summary>
    /// Type of the service factory
    /// </summary>
    public enum ServiceFactoryType
    {
        Server,

        Proxy,

        Test
    }

    /// <summary>
    /// 
    /// </summary>
    public abstract class ServiceAbstractFactory
    {
        /// <summary>
        /// Current context of the application
        /// </summary>
        public ServiceContext CurrentContext
        {
            get;
            set;
        }

        /// <summary>
        /// Create the instance of the factory for the different purpose
        /// </summary>
        /// <param name="factoryType">The factory we want to use</param>
        /// <returns>The instance of the factory</returns>
        public static ServiceAbstractFactory CreateFactory(ServiceFactoryType factoryType)
        {
            ServiceAbstractFactory factory = null;
            switch (factoryType)
            {
                case ServiceFactoryType.Server:
                    factory = FactoryLoadUtility.LoadFactory<ServiceAbstractFactory>("Majoopic.Service.Server.dll", "Majoopic.Service.Server.ServiceServerFactory");
                    break;
                case ServiceFactoryType.Proxy:
                    factory = FactoryLoadUtility.LoadFactory<ServiceAbstractFactory>("Majoopic.Service.Proxy.dll", "Majoopic.Service.Proxy.ServiceProxyFactory");
                    break;
                case ServiceFactoryType.Test:
                    factory = FactoryLoadUtility.LoadFactory<ServiceAbstractFactory>("Majoopic.Service.Test.dll", "Majoopic.Service.Test.ServiceTestFactory");
                    break;
                default:
                    throw new ArgumentException("The factoryType is not valid");
            }
            return factory;
        }

        /// <summary>
        /// Get the picture service
        /// </summary>
        /// <returns></returns>
        public virtual IPictureService GetPictureService()
        {
            throw new NotImplementedException();
        }
    }
}
